<?php defined('IN_ADMIN') or exit('No permission resources.');?>
<?php include $this->admin_tpl('header', 'admin');?>

<link href="<?php echo CSS_PATH?>showLoading.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo JS_PATH?>jquery.form.js"></script>
<script type="text/javascript" src="<?php echo JS_PATH?>jquery.showLoading.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
    $('#myform').ajaxForm({  
        beforeSubmit: validate,
        success: showResponse,
        timeout: 10000
    });
});

function validate(formData, jqForm, options) {
    $("#loadingImg").showLoading();
}

function showResponse(responseText, statusText) {
    var result = $.parseJSON(responseText);
    $("#loadingImg").hideLoading();
    
    if(result && result.status) {
        window.parent.right.location.reload();
        window.parent.top.art.dialog({id:'upgrade'}).close();
    }else if(result && result.status == false) {
        window.parent.right.Alert(result.info + "！", '<?php echo IMG_PATH?>icon/alert.png');
    }else {
        window.parent.right.Alert("网络异常，请联系管理员！", '<?php echo IMG_PATH?>icon/error.png');
    }
}
</script>

<div class="pad-10">
<div class="common-form">

<form name="myform" action="?m=member&c=member&a=upgrade_to_admin" method="post" id="myform">
    <input type="hidden" name="info[userid]" id="userid" value="<?php echo $memberinfo['userid']?>"></input>
    <input type="hidden" name="info[username]" value="<?php echo $memberinfo['username']?>"></input>
    <input type="hidden" name="info[email]" value="<?php echo $memberinfo['email']?>"></input>
<fieldset>
	<legend><?php echo L('basic_configuration')?></legend>
	<table width="100%" class="table_form">
            <tr>
                <td width="80"><?php echo L('username') ?></td> 
                <td><?php echo $memberinfo['username'] ?><?php if ($memberinfo['islock']) { ?><img title="<?php echo L('lock') ?>" src="<?php echo IMG_PATH ?>icon/icon_padlock.gif"><?php } ?><?php if ($memberinfo['vip']) { ?><img title="<?php echo L('lock') ?>" src="<?php echo IMG_PATH ?>icon/vip.gif"><?php } ?></td>
            </tr>
            <tr>
                <td><?php echo L('nickname') ?></td> 
                <td><?php echo $memberinfo['nickname'] ?></td>
            </tr>
            <tr>
                <td><?php echo L('email') ?></td>
                <td><?php echo $memberinfo['email'] ?></td>
            </tr>
            <tr>
                <td><?php echo L('mp') ?></td>
                <td><?php echo $memberinfo['mobile'] ?></td>
            </tr>
            <tr>
                <td><?php echo L('member_group') ?></td>
                <td><?php echo $grouplist[$memberinfo['groupid']] ?></td>
            </tr>
	</table>
</fieldset>
<div class="bk15"></div>
<fieldset>
    <legend>管理员角色</legend>
    <table width="100%" class="table_form">
            <tr>
                <td width="80">管理员角色</td> 
                <td>
                    <select name="info[roleid]">
                    <?php 
                    foreach($roles as $role) {
                    ?>
                    <option value="<?php echo $role['roleid']?>"><?php echo $role['rolename']?></option>
                    <?php 
                    }
                    ?>
                    </select>
                    <span id="loadingImg" style="margin-left: 30px;"></span>
                </td>
            </tr>
	</table>
</fieldset>
<input type="submit" name="dosubmit" id="dosubmit" value="dosubmit" style="display: none;" />
</form>
<div class="bk15"></div>
<div class="bk15"></div>
</div>
</div>
</body>
</html>